<table id="alist"></table>
<div id="alistToolbar" style="padding:5px;">
	任务名称：<input id="aname" class="easyui-textbox" style="width:150px">&nbsp;
	资源库名称：<input id="arepName" class="easyui-textbox" style="width:150px">&nbsp;
	脚本名称：<input id="ascriptName" class="easyui-textbox" style="width:150px">&nbsp;
	脚本类型：<select id="ascriptType" class="easyui-combobox" data-options="panelHeight:'auto'" style="width:80px;">
		<option value="transformation">转化</option>
		<option value="job">作业</option>
	</select>&nbsp;
	<a href="javascript:asearch()" class="easyui-linkbutton" iconCls="icon-search">查询</a>&nbsp;
	<a href="javascript:areset()" class="easyui-linkbutton" iconCls="icon-undo">重置</a>&nbsp;
</div>
<div id="arecDia" class="easyui-dialog" data-options="title:'执行记录',closed:true,modal:true" style="width:770px;height:500px;">
    <table id="arecDiaList"></table>
</div>

	
<script type="text/javascript" src="cusy/js/task.js"></script>
<script type="text/javascript">
$(function() {
	let fcolumns = [[
		{field:'name', title:'任务名称', halign:'center', width:180},
		{field:'repName', title:'资源库名称', halign:'center', width:180},
		{field:'repType', title:'资源库类型', halign:'center', width:80, formatter:function(value, row, index){
			if (value == 'file') return '文件';
			else if (value == 'db') return '数据库';
			else value;
		}},
		{field:'scriptName', title:'脚本名称', halign:'center', width:180},
		{field:'scriptPath', title:'脚本路径', halign:'center', width:300},
		{field:'scriptType', title:'脚本类型', halign:'center', width:60, formatter:function(value, row, index){
			if ("transformation" == value) return "转换";
			if ("job" == value) return "作业";
			return "";
		}},
		{field:'cron', title:'cron表达式', halign:'center', width:160},
		{field:'status', title:'状态', halign:'center', width:50, formatter:function(value, row, index){
			if ('stop' == value) return "<span style='color:red'>已停止</span>";
			if ('run' == value) return "<span style='color:green'>运行中</span>";
			return '';
		}},
		{field:'id', title:'操作', halign:'center', width:255, formatter:function(value, row, index){
			let html = '', chtml = '<a class="k1Oper" href="javascript:a';
			if ('stop' == row.status) {
				html += chtml + 'start(\''+value+'\')"><i class="fa fa-hourglass-start fa-lg"></i> 启动</a>'
				html += chtml + 'editPage(\''+value+'\')"><i class="fa fa-edit fa-lg"></i> 编辑</a>';
				html += chtml + 'delete(\''+value+'\',\''+row.name+'\')" style="color:red"><i class="fa fa-trash fa-lg"></i> 删除</a>';
			} else if ('run' == row.status) {
				html +=  chtml + 'stop(\''+value+'\')"><i class="fa fa-stop-circle-o fa-lg"></i> 停止</a>';
			}
			html +=  chtml + 'history(\''+value+'\')"><i class="fa fa-history fa-lg"></i> 执行记录</a>'
			return html;
		}}
	]];
	$(ascriptType).combobox("clear");
	datagridInit(alist, fcolumns, '资源库列表', 'alistToolbar', alistLoader, alistLoaderComplete);
});
</script>